package com.workerhelping.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.workerhelping.dao.ConfirmDao;
import com.workerhelping.enums.OperationEnum;
import com.workerhelping.enums.StatusEnum;
import com.workerhelping.po.Confirm;
import com.workerhelping.service.ConfirmService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class ConfirmServiceImpl extends ServiceImpl<ConfirmDao, Confirm> implements ConfirmService {

    @Override
    public List<Confirm> getConfirmByWorkerId(Integer id) {
        QueryWrapper<Confirm> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("w_id", id);
        List<Confirm> confirms = baseMapper.selectList(queryWrapper);
        return confirms;
    }

    @Override
    public void deleteConfirmById(Integer id) {
        Confirm confirm = baseMapper.selectById(id);
        confirm.setChecked(1);
        baseMapper.updateById(confirm);
    }

}
